﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using _PLATFORM.DATA;

namespace _PLATFORM.WEB.Controllers
{
    public class HomeController : Controller
    {
        private eCommPlatformRepoEntities db = new eCommPlatformRepoEntities();

        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";
            SomeName();
            return View();
        }

        public ActionResult ResellerIndex(TEMPLATE ResellerTemplate)
        {
            // Specify The Site Owner
            DATA.Custom_Classes.User.ParentID = ResellerTemplate.USER_ID;
            DATA.Custom_Classes.User.SeedIdentified = true;

            ViewBag.Message = string.Format("Welcome To The Website For {0}", ResellerTemplate.NAME);
            ViewBag.Logo = ResellerTemplate.LOGO;
            ViewBag.LogoAltText = string.Format("Logo For {0}", ResellerTemplate.NAME);
            SomeName();
            return View();
        }

        public ActionResult About()
        {
            return View();
        }

        private void SomeName()
        {
            // Find The Default Account's User ID To Set As Parent ID
            var parent = Membership.GetUser(ConfigurationSettings.AppSettings["ProductOwnerUserName"]);
            DATA.Custom_Classes.User.ParentID = Guid.Parse(parent.ProviderUserKey.ToString());

            //var thisUser = db.RESELLERs.Where(r => r.USER_ID == DATA.Custom_Classes.User.ParentID).ToList()[0];
            ViewBag.CompanyName = "[HA SHEM]";
        }
    }
}
